import { RoleQueryParam, RoleItem, RolePageResult, RoleFormData } from '@/types/api/sys/role';
import request from '@/utils/request';
import { AxiosPromise } from 'axios';
//import qs from 'qs';

export default {
	/**
	 * 分页查询数据
	 * @param query
	 * @return AxiosPromise<RolePageResult> 
	 */
	fetchList: function(query?: RoleQueryParam): AxiosPromise<RolePageResult> {
		return request({
			url: '/api/sys/Sysrole/list',
			method: 'get',
			params: query
		})
	},
	/**
	 * 根据id查询详情
	 * @param {number} id
	 * @return AxiosPromise<RoleFormData>
	 */
	fetchOne: function(id: number): AxiosPromise<RoleItem> {
		return request({
			url: '/api/sys/Sysrole/get/' + id,
			method: 'get'
		})
	},
	/**
	 * 根据id删除，多个以英文逗号(,)分割
	 *
	 * @param {number|string} id
	 */
	delete: function(id: any) {
		return request({
			url: '/api/sys/Sysrole/delete/' + id,
			method: 'get'
			/*,params: { pv }*/
		})
	},
	/**
	 * 添加
	 */
	add: function(data: RoleFormData) {
		return request({
			url: '/api/sys/Sysrole/add',
			method: 'post',
			data
		})
	},
	/**
	 * 更新
	 * @param {Object} data
	 */
	update: function(data: RoleFormData) {
		return request({
			url: '/api/sys/Sysrole/update',
			method: 'post',
			data
		})
	}
}
